home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.ada,comp.lang.c++
- Subject: Re: on OO differnces between Ada95 and C++
- Date: 26 Feb 1996 19:57:04 GMT
- Organization: Borland International
- Message-ID: <4gt3ag$76m@druid.borland.com>
- References: <4gbq7q$g08@qualcomm.com> <3129F185.41C6@Rational.COM> <4gi413$qo1@druid.borland.com> <4gspen$ot0@hacgate2.hac.com>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <4gspen$ot0@hacgate2.hac.com>, ddavenpo@redwood.hac.com says...
- >
- >Pete Becker (pete@borland.com) wrote:
- >: In article <3129F185.41C6@Rational.COM>, jDesquilbet@Rational.COM says...
- >: >
- >: >- you may have several different definitions for the same class in the
- >: >same program, as long as they are never compiled together in the same
- >: >compilation unit; example:
- >: >
- >: >#define private public // *** BERK! ***
- >: >#include "...h" // second definition for the same class
- >: >#undef private
- >
- >: This is not true. A program that attempts to do this violates the one
- >: definition rule, so it is not a legal C++ program.
- >: -- Pete
- >
- >We need to be careful here with terms used to describe C++ constructs.
- >A class name declaration is a C++ declaration (ARM C++ 3.1) not a definition.
-
- This is a red herring. The issue is not about a "class name declaration", but
- about the actual definition of the class.
-
- >This is what is specified in ".h" files. There can be multiple declarations
- >so the above code is legal C++ code.
-
- There can be multiple declarations of the name, but that is irrelevant.
-
- >There can only be one definition
- >of each object, function, class, and enumerator in a program and these
- >are specified in ".cc" files. Mr. Becker is correct about stating that
- >there must be only one definition but that rule does not apply in this
- >instance.
-
- No, my original statement is correct: a program which contains multiple
- definitions of the same class is not a valid C++ program because it violates
- the one definition rule. That is exactly the case that the original message
- attempts to create, as indicated by the prefatory text which says "you may
- have several different definitions for the same class in the same program, as
- long as they are never compiled together in the same compilation unit" and by
- the comment that says "second definition for the same class". You MAY NOT have
- several definitions for the same class in the same program. Changing private
- members to public creates a different definition of the class and is illegal.
- Class definitions are not local to a compilation unit, and cannot be treated
- so cavalierly. There aren't many compilers that enforce this rule, but it is
- nevertheless a constraint on valid C++ programs.
- -- Pete
-
-